//
//  NSString+ACPStringExtension.m
//  AutoCreatePropertyDemo
//
//  Created by Hongwei Wang on 2017/11/29.
//  Copyright © 2017年 puhui. All rights reserved.
//

#import "NSString+ACPStringExtension.h"

@implementation NSString (ACPStringExtension)

- (NSString *)handel_path {
    if (!self.length) {
        return self;
    }
    NSString *result_str;
    NSString *last_char = [self substringWithRange:NSMakeRange(self.length - 1, 1)];
    if ([last_char isEqualToString:@"/"]) {
        result_str = [self substringToIndex:self.length - 1];
    } else {
        result_str = self;
    }
    return result_str;
}

- (NSString *)to_base64 {
    NSData *encodeData = [self dataUsingEncoding:NSUTF8StringEncoding];
    NSString *base64String = [encodeData base64EncodedStringWithOptions:0];
    return base64String;
}

- (NSString *)base64_to_normal {
    NSData *decodedData = [[NSData alloc] initWithBase64EncodedString:self options:0];
    NSString *decodedString = [[NSString alloc] initWithData:decodedData encoding:NSUTF8StringEncoding];
    return decodedString;
}

@end
